<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>综合练习</title>
</head>
<body>
<div>
    <input type="text" placeholder="员工姓名" v-model="emp.name">
    <input type="text" placeholder="员工工资" v-model="emp.sal">
    <input type="text" placeholder="员工工作" v-model="emp.job">
    <input type="button" value="添加" @click="f()">
    <table border="1">
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>工资</th>
            <th>工作</th>
            <th>操作</th>
        </tr>
        <tr v-for="(e,i) in arr">
            <td>{{i+1}}</td>
            <td>{{e.name}}</td>
            <td>{{e.sal}}</td>
            <td>{{e.job}}</td>
            <td><input type="button" value="删除" @click="del(i)"></td>
        </tr>
    </table>
</div>
<script src="http://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            emp:{name:"",sal:"",job:""},
            arr:[]
        },
        methods:{
            f(){
              v.arr.push({name:v.emp.name,sal:v.emp.sal,job:v.emp.job})
            },
            del(i){
                v.arr.splice(i,1)
            }
        }
    })
</script>
</body>
</html>